package us.wili.dev.third.util.example.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import us.wili.dev.common.util.sms.aliyun.AliyunSmsProperties;
import us.wili.dev.common.util.sms.aliyun.AliyunSmsUtil;
import us.wili.dev.common.util.trtc.TrtcProperties;
import us.wili.dev.common.util.trtc.WebRTCSigUtil;

/**
 * author: lefore
 * date: 2018/10/22
 */
@Configuration
@EnableConfigurationProperties({TrtcConfig.TrtcPropertiesCreator.class})
public class TrtcConfig {

    @Bean
    public WebRTCSigUtil webRTCSigUtil(TrtcPropertiesCreator propCreator) {
        TrtcProperties prop = propCreator.getTrtc();
        return new WebRTCSigUtil(prop);
    }

    @Bean
    public AliyunSmsUtil aliyunSmsUtil(SmsConfig.SmsPropertiesCreator propCreator) {
        AliyunSmsProperties prop = propCreator.getSms();
        return new AliyunSmsUtil(prop);
    }

    @ConfigurationProperties
    public static class TrtcPropertiesCreator {

        private TrtcProperties trtc;

        public TrtcProperties getTrtc() {
            return trtc;
        }

        public void setTrtc(TrtcProperties trtc) {
            this.trtc = trtc;
        }
    }
}